Skip to content

fix(OAuth2API): enable token exchange without token #10312

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 2 commits into from
Jun 2, 2024

Conversation

Gravitonic
Copy link
Contributor

Please describe the changes this PR makes and why it should be merged: Currently, requests made by the OAuth2API class require the Authorization header by default. If no token is set on the underlying REST client, this produces an error:

Error: Expected token to be set for this request, but none was present

However, for requests such as exchanging an authorization code for a token or refreshing using a refresh token, an existing token isn't required by the Discord API and doesn't really make sense; if the client already has a valid token, there's no need to exchange a code for a new token. (See here for a simple StackBlitz reproduction.) This PR disables the Authorization header for these requests.

Status and versioning classification:

  • Code changes have been tested against the Discord API, or there are no code changes
  • I know how to update typings and have done so, or typings don't need updating

@Gravitonic Gravitonic requested a review from a team as a code owner June 2, 2024 07:54
Copy link

vercel bot commented Jun 2, 2024

The latest updates on your projects. Learn more about Vercel for Git ↗︎

2 Ignored Deployments
Name Status Preview Comments Updated (UTC)
discord-js ⬜️ Ignored (Inspect) Visit Preview Jun 2, 2024 1:15pm
discord-js-guide ⬜️ Ignored (Inspect) Visit Preview Jun 2, 2024 1:15pm

Copy link

codecov bot commented Jun 2, 2024

Codecov Report

Attention: Patch coverage is 0% with 3 lines in your changes are missing coverage. Please review.

Project coverage is 0.00%. Comparing base (c1e6890) to head (9ee37cc).

Files Patch % Lines
packages/core/src/api/oauth2.ts 0.00% 3 Missing ⚠️
Additional details and impacted files
@@             Coverage Diff             @@
##             main   #10312       +/-   ##
===========================================
- Coverage   95.89%    0.00%   -95.90%     
===========================================
  Files          44       18       -26     
  Lines        3634     3967      +333     
  Branches      111       18       -93     
===========================================
- Hits         3485        0     -3485     
- Misses        149     3967     +3818     
Flag Coverage Δ
brokers 0.00% <0.00%> (-95.90%) ⬇️
builders 0.00% <0.00%> (-95.90%) ⬇️
collection 0.00% <0.00%> (-95.90%) ⬇️
discord.js 0.00% <0.00%> (-95.90%) ⬇️
formatters 0.00% <0.00%> (-95.90%) ⬇️
guide 0.00% <0.00%> (-95.90%) ⬇️
next 0.00% <0.00%> (-95.90%) ⬇️
proxy 0.00% <0.00%> (-95.90%) ⬇️
rest 0.00% <0.00%> (-95.90%) ⬇️
util 0.00% <0.00%> (-95.90%) ⬇️
utilities 0.00% <0.00%> (-95.90%) ⬇️
voice 0.00% <0.00%> (-95.90%) ⬇️
website 0.00% <0.00%> (-95.90%) ⬇️
ws 0.00% <0.00%> (-95.90%) ⬇️

Flags with carried forward coverage won't be shown. Click here to find out more.

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

@kodiakhq kodiakhq bot merged commit 9b07036 into discordjs:main Jun 2, 2024
22 checks passed
@Jiralite Jiralite added this to the core 1.3.0 milestone Jun 2, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
Archived in project
Development

Successfully merging this pull request may close these issues.

5 participants